package C6;

public class Student implements Comparable<Student> {
    private String  name;
    private int Age;
    private String stuNo;
    private double weight;

    public Student() {
    }

    public Student(String name, int age, String stuNo, double weight) {
        this.name = name;
        Age = age;
        this.stuNo = stuNo;
        this.weight = weight;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return Age;
    }

    public void setAge(int age) {
        Age = age;
    }

    public String getStuNo() {
        return stuNo;
    }

    public void setStuNo(String stuNo) {
        this.stuNo = stuNo;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", Age=" + Age +
                ", stuNo='" + stuNo + '\'' +
                ", weight=" + weight +
                '}';
    }

    @Override
    public int compareTo(Student o) {
            //将object强转为当前类型
            Student stu = (Student)o;
            //排序规则
            if(o.Age > getAge()){
                //负数 o比当前实例小
                return  -1;
            }else if(o.Age < getAge()){
                //正数 o比当前实例大
                return 1;
            }
            else {
                return 0;}
    }
}
